-- adjustment is stable.
return True
-{- Passed an action that, if it succeeds may get or drop the Key associated
- - with the file. When the adjusted branch needs to be refreshed to reflect
+{- Passed an action that, if it succeeds may get or drop a key.
+ - When the adjusted branch needs to be refreshed to reflect
- those changes, it's handled here.
- -
- - Note that the AssociatedFile must be verified by this to point to the
- - Key. In some cases, the value was provided by the user and might not
- - really be an associated file.
-}
-adjustedBranchRefresh :: AssociatedFile -> Annex a -> Annex a
-adjustedBranchRefresh _af a = do
+adjustedBranchRefresh :: Annex a -> Annex a
+adjustedBranchRefresh a = do
r <- a
go
return r
{- Runs an action, passing it the temp file to get,
- and if the action succeeds, verifies the file matches
- the key and moves the file into the annex as a key's content. -}
-getViaTmp :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> AssociatedFile -> Maybe FileSize -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
-getViaTmp rsp v key af sz action =
+getViaTmp :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> Maybe FileSize -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
+getViaTmp rsp v key sz action =
checkDiskSpaceToGet key sz False $
- getViaTmpFromDisk rsp v key af action
+ getViaTmpFromDisk rsp v key action
{- Like getViaTmp, but does not check that there is enough disk space
- for the incoming key. For use when the key content is already on disk
- and not being copied into place. -}
-getViaTmpFromDisk :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> AssociatedFile -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
-getViaTmpFromDisk rsp v key af action = checkallowed $ do
+getViaTmpFromDisk :: RetrievalSecurityPolicy -> VerifyConfig -> Key -> (OsPath -> Annex (Bool, Verification)) -> Annex Bool
+getViaTmpFromDisk rsp v key action = checkallowed $ do
tmpfile <- prepTmp key
resuming <- liftIO $ doesPathExist tmpfile
(ok, verification) <- action tmpfile
else verification
if ok
then ifM (verifyKeyContentPostRetrieval rsp v verification' key tmpfile)
- ( pruneTmpWorkDirBefore tmpfile (moveAnnex key af)
+ ( pruneTmpWorkDirBefore tmpfile (moveAnnex key)
, do
verificationOfContentFailed tmpfile
return False
- accepted into the repository. Will display a warning message in this
- case. May also throw exceptions in some cases.
-}
-moveAnnex :: Key -> AssociatedFile -> OsPath -> Annex Bool
-moveAnnex key af src = ifM (checkSecureHashes' key)
+moveAnnex :: Key -> OsPath -> Annex Bool
+moveAnnex key src = ifM (checkSecureHashes' key)
( do
#ifdef mingw32_HOST_OS
{- Windows prevents deletion of files that are not
where
storeobject dest = ifM (liftIO $ doesPathExist dest)
( alreadyhave
- , adjustedBranchRefresh af $ modifyContentDir dest $ do
+ , adjustedBranchRefresh $ modifyContentDir dest $ do
liftIO $ moveFile src dest
-- Freeze the object file now that it is in place.
-- Waiting until now to freeze it allows for freeze
-- it's unmodified.
resetpointer file = unlessM (liftIO $ isSymbolicLink <$> R.getSymbolicLinkStatus (fromOsPath file)) $
ifM (isUnmodified key file)
- ( adjustedBranchRefresh (AssociatedFile (Just file)) $
+ ( adjustedBranchRefresh $
depopulatePointerFile key file
-- Modified file, so leave it alone.
-- If it was a hard link to the annex object,
ia loc [cid] tmpfile
(Left k)
(combineMeterUpdate p' p)
- ok <- moveAnnex k af tmpfile
+ ok <- moveAnnex k tmpfile
when ok $
logStatus NoLiveUpdate k InfoPresent
return (Just (k, ok))
p
case keyGitSha k of
Nothing -> do
- ok <- moveAnnex k af tmpfile
+ ok <- moveAnnex k tmpfile
when ok $ do
recordcidkey cidmap cid k
logStatus NoLiveUpdate k InfoPresent
| otherwise = gounlocked key mcache
golocked key mcache =
- tryNonAsync (moveAnnex key naf (contentLocation source)) >>= \case
+ tryNonAsync (moveAnnex key (contentLocation source)) >>= \case
Right True -> success key mcache
Right False -> giveup "failed to add content to annex"
Left e -> restoreFile (keyFilename source) key e
- -- moveAnnex uses the AssociatedFile provided to it to unlock
- -- locked files when getting a file in an adjusted branch.
- -- That case does not apply here, where we're adding an unlocked
- -- file, so provide it nothing.
- naf = AssociatedFile Nothing
-
gounlocked key (Just cache) = do
-- Remove temp directory hard link first because
-- linkToAnnex falls back to copying if a file
stagePointerFile file mode =<< hashPointerFile key
Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath file)
case mtmp of
- Just tmp -> ifM (moveAnnex key af tmp)
+ Just tmp -> ifM (moveAnnex key tmp)
( linkunlocked mode >> return True
, writepointer mode >> return False
)
, do
addSymlink file key Nothing
case mtmp of
- Just tmp -> moveAnnex key af tmp
+ Just tmp -> moveAnnex key tmp
Nothing -> return True
)
where
- af = AssociatedFile (Just file)
mi = case mtmp of
Just tmp -> MatchingFile $ FileInfo
{ contentFile = tmp
Just StallDetectionDisabled -> go Nothing
Just sd -> runTransferrer sd r key f d Download witness
where
- go sd = getViaTmp (Remote.retrievalSecurityPolicy r) vc key f Nothing $ \dest ->
+ go sd = getViaTmp (Remote.retrievalSecurityPolicy r) vc key Nothing $ \dest ->
download' (Remote.uuid r) key f sd d (go' dest) witness
go' dest p = verifiedAction $
Remote.retrieveKeyFile r key f dest p vc
getexport loc = catchNonAsync (getexport' loc) (const (pure False))
getexport' loc =
- getViaTmp rsp vc k (AssociatedFile Nothing) Nothing $ \tmp -> do
+ getViaTmp rsp vc k Nothing $ \tmp -> do
v <- Remote.retrieveExport (Remote.exportActions rmt)
k loc tmp nullMeterUpdate
return (True, v)
tmp nullMeterUpdate
if (bundlekey `notElem` inManifest manifest)
then do
- unlessM (moveAnnex bundlekey (AssociatedFile Nothing) tmp) $
+ unlessM (moveAnnex bundlekey tmp) $
giveup "Unable to push"
return (bundlekey, uploadaction bundlekey)
else return (bundlekey, noop)
warning $ "Received a file " <> QuotedPath f <> " that is not a git-annex key. Deleting this file."
liftIO $ removeWhenExistsWith removeFile f
Just k -> void $ logStatusAfter NoLiveUpdate k $
- getViaTmpFromDisk RetrievalVerifiableKeysSecure AlwaysVerify k (AssociatedFile Nothing) $ \dest -> unVerified $
+ getViaTmpFromDisk RetrievalVerifiableKeysSecure AlwaysVerify k $ \dest -> unVerified $
liftIO $ catchBoolIO $ do
renameFile f dest
return True
- and vulnerable to corruption. -}
linkKey' :: VerifyConfig -> Key -> Key -> Annex Bool
linkKey' v oldkey newkey =
- getViaTmpFromDisk RetrievalAllKeysSecure v newkey (AssociatedFile Nothing) $ \tmp -> unVerified $ do
+ getViaTmpFromDisk RetrievalAllKeysSecure v newkey $ \tmp -> unVerified $ do
oldobj <- calcRepo (gitAnnexLocation oldkey)
isJust <$> linkOrCopy' (return True) newkey oldobj tmp Nothing
start (_, key) = fieldTransfer Download key $ \_p -> do
-- This matches the retrievalSecurityPolicy of Remote.Git
let rsp = RetrievalAllKeysSecure
- ifM (getViaTmp rsp DefaultVerify key (AssociatedFile Nothing) Nothing go)
+ ifM (getViaTmp rsp DefaultVerify key Nothing go)
( do
logStatus NoLiveUpdate key InfoPresent
_ <- quiesce True
)
where
move = checkDiskSpaceToGet key Nothing False $
- moveAnnex key (AssociatedFile Nothing) src
+ moveAnnex key src
cleanup :: Key -> CommandCleanup
cleanup key = do
-- the file might be on a different filesystem, so moveFile is used
-- rather than simply calling moveAnnex; disk space is also
-- checked this way.
- ok <- getViaTmp RetrievalAllKeysSecure DefaultVerify key (AssociatedFile Nothing) Nothing $ \dest -> unVerified $
+ ok <- getViaTmp RetrievalAllKeysSecure DefaultVerify key Nothing $ \dest -> unVerified $
if dest /= file
then liftIO $ catchBoolIO $ do
moveFile file dest
Just verifier -> do
loc <- Annex.calcRepo (gitAnnexLocation k)
verifier k loc
- get r k = logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k (AssociatedFile Nothing) Nothing $ \dest ->
+ get r k = logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k Nothing $ \dest ->
tryNonAsync (Remote.retrieveKeyFile r k (AssociatedFile Nothing) dest nullMeterUpdate (RemoteVerify r)) >>= \case
Right v -> return (True, v)
Left _ -> return (False, UnVerified)
, check (`notElem` [Right True, Right False]) "checkPresent" $ \r k ->
Remote.checkPresent r k
, check (== Right False) "retrieveKeyFile" $ \r k ->
- logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k (AssociatedFile Nothing) Nothing $ \dest ->
+ logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k Nothing $ \dest ->
tryNonAsync (Remote.retrieveKeyFile r k (AssociatedFile Nothing) dest nullMeterUpdate (RemoteVerify r)) >>= \case
Right v -> return (True, v)
Left _ -> return (False, UnVerified)
, check (== Right False) "retrieveKeyFileCheap" $ \r k -> case Remote.retrieveKeyFileCheap r of
Nothing -> return False
- Just a -> logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k (AssociatedFile Nothing) Nothing $ \dest ->
+ Just a -> logStatusAfter NoLiveUpdate k $ getViaTmp (Remote.retrievalSecurityPolicy r) (RemoteVerify r) k Nothing $ \dest ->
unVerified $ isRight
<$> tryNonAsync (a k (AssociatedFile Nothing) dest)
]
k <- case Types.Backend.genKey Backend.Hash.testKeyBackend of
Just a -> a ks nullMeterUpdate
Nothing -> giveup "failed to generate random key (backend problem)"
- _ <- moveAnnex k (AssociatedFile Nothing) f
+ _ <- moveAnnex k f
return k
getReadonlyKey :: Remote -> OsPath -> Annex Key
fromPerform :: Key -> AssociatedFile -> Remote -> CommandPerform
fromPerform key af remote = go Upload af $
download' (uuid remote) key af Nothing stdRetry $ \p ->
- logStatusAfter NoLiveUpdate key $ getViaTmp (retrievalSecurityPolicy remote) vc key af Nothing $ \t ->
+ logStatusAfter NoLiveUpdate key $ getViaTmp (retrievalSecurityPolicy remote) vc key Nothing $ \t ->
tryNonAsync (Remote.retrieveKeyFile remote key af t p vc) >>= \case
Right v -> return (True, v)
Left e -> do
return True
| otherwise = notifyTransfer direction af $
download' (Remote.uuid remote) key af Nothing stdRetry $ \p ->
- logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key af Nothing $ \t -> do
+ logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key Nothing $ \t -> do
r <- tryNonAsync (Remote.retrieveKeyFile remote key af t p (RemoteVerify remote)) >>= \case
Left e -> do
warning (UnquotedString (show e))
-- so caller is responsible for doing notification
-- and for retrying, and updating location log,
-- and stall canceling.
- let go p = getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key af Nothing $ \t -> do
+ let go p = getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key Nothing $ \t -> do
Remote.verifiedAction (Remote.retrieveKeyFile remote key af t p (RemoteVerify remote))
in download' (Remote.uuid remote) key af Nothing noRetry go
noNotification
runner (AssistantDownloadRequest _ key (TransferAssociatedFile file)) remote =
notifyTransfer Download file $
download' (Remote.uuid remote) key file Nothing stdRetry $ \p ->
- logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key file Nothing $ \t -> do
+ logStatusAfter NoLiveUpdate key $ getViaTmp (Remote.retrievalSecurityPolicy remote) (RemoteVerify remote) key Nothing $ \t -> do
r <- tryNonAsync (Remote.retrieveKeyFile remote key file t p (RemoteVerify remote)) >>= \case
Left e -> do
warning (UnquotedString (show e))
iv <- startVerifyKeyContentIncrementally DefaultVerify k
let runtransfer ti =
Right <$> transfer download' k af Nothing (\p ->
- logStatusAfter NoLiveUpdate k $ getViaTmp rsp DefaultVerify k af Nothing $ \tmp ->
+ logStatusAfter NoLiveUpdate k $ getViaTmp rsp DefaultVerify k Nothing $ \tmp ->
storefile tmp o l getb iv validitycheck p ti)
let fallback = return $ Left $
ProtoFailureMessage "transfer already in progress, or unable to take transfer lock"
let checksuccess = liftIO checkio >>= \case
Just err -> giveup err
Nothing -> return True
- logStatusAfter NoLiveUpdate key $ Annex.Content.getViaTmp rsp verify key af (Just sz) $ \dest ->
+ logStatusAfter NoLiveUpdate key $ Annex.Content.getViaTmp rsp verify key (Just sz) $ \dest ->
metered (Just (combineMeterUpdate meterupdate p)) key bwlimit $ \_ p' ->
copier object dest key p' checksuccess verify
)
olddir <- fromRepo gitAnnexDir
keys <- getKeysPresent0 olddir
forM_ keys $ \k ->
- moveAnnex k (AssociatedFile Nothing)
- (olddir </> toOsPath (keyFile0 k))
+ moveAnnex k (olddir </> toOsPath (keyFile0 k))
-- update the symlinks to the key files
-- No longer needed here; V1.upgrade does the same thing
let d = parentDir f
liftIO $ allowWrite d
liftIO $ allowWrite f
- _ <- moveAnnex k (AssociatedFile Nothing) f
+ _ <- moveAnnex k f
liftIO $ removeDirectory d
updateSymlinks :: Annex ()